// #region 路由
import 'package:tetap_ad_batch/pages/dashboard/dashboard_layout.dart';
import 'package:tetap_ad_batch/pages/dashboard/dashboard_page.dart';
import 'package:tetap_ad_batch/pages/dashboard/test_page.dart';
import 'package:tetap_ad_batch/router/fade_in_transition_page.dart';
// #endregion

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

enum RouteEnum {
  dashboard('dashboard', '/'),
  test('test', '/test');

  final String name;
  final String path;
  const RouteEnum(this.name, this.path);
}


class RouterUtils extends RouterConfig<Object> {
  static final GoRouter routes = GoRouter(
    initialLocation: '/',
    routes: [
      StatefulShellRoute.indexedStack(
        pageBuilder: (context, state, navigationShell) {
          return FadeTransitionPage(
            key: state.pageKey,
            child: DashboardLayout(navigationShell: navigationShell),
          );
        },
        branches: <StatefulShellBranch>[
          StatefulShellBranch(
            routes: <RouteBase>[
              GoRoute(
                  name: RouteEnum.dashboard.name,
                  path: RouteEnum.dashboard.path,
                  builder: (BuildContext context, GoRouterState state) =>
                      DashboardPage(key: state.pageKey)),
            ],
          ),
          StatefulShellBranch(
            routes: <RouteBase>[
              GoRoute(
                  name: RouteEnum.test.name,
                  path: RouteEnum.test.path,
                  builder: (BuildContext context, GoRouterState state) =>
                      TestPage(key: state.pageKey)),
            ],
          ),
        ],
      ),
    ],
  );

  RouterUtils({required super.routerDelegate});
}
